#@layout()

#define content()

<div id="datagridId"></div>

<div id="datagridTb">
    <a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true"
       id='file_box_remove'>删除文件</a>
</div>
#end


#define css()

#end


#define js()
<script type="text/javascript">
    var _datagrid = "datagridId", _form = "formId", _datagridTb = "datagridTb";
    var datagridListUrl = contextRootPath + '/fileBoxList?fileBox.zone_id=#(fileZone.zone_id)';

    $(function () {

        //初始化表格
        $("#" + _datagrid).datagrid({
            title: '#(fileZone.zone_name)',
            url: datagridListUrl,
            fit: true,
            border: false,
            rownumbers: true,
            pageSize: 30,
            toolbar: '#' + _datagridTb,
            singleSelect: false,
            pagination: true,
            nowrap: false,
            striped: true,
            fitColumns: true,
            columns: [[
                {field: 'file_id', title: 'file_id', width: 100, checkbox: true},
                {
                    field: 'url',
                    title: "文件地址"
                },
                {
                    field: 'delete_time',
                    title: "删除时间"
                },
                {
                    field: 'is_delete',
                    title: "是否删除",
                    formatter: function (value, row, index) {
                        if (value === 1) {
                            return '已删除';
                        } else {
                            return '未删除';
                        }
                    }
                },
                {
                    field: 'createts',
                    title: "创建时间"
                }
            ]]
        });


        $("#file_box_remove").on('click', function () {
            var selections = $('#' + _datagrid).datagrid('getSelections');
            var ids = "";

            if (selections.length < 1) {
                $.messager.alert("提示框", "请选择需要操作的文件!", "warning");
                return;
            }

            $.messager.confirm('确认框', '请确定需要删除所选择的文件么？', function (r) {
                if (r) {
                    $.each(selections, function (i, v) {
                        ids += v['file_id'] + ",";
                    });

                    $.post(contextRootPath + "/fileBoxRemove/" + ids, function (data) {
                        var params = {};
                        params.element = _datagrid;
                        params.data = data;
                        params.isClose = false;
                        resultCallback(params);
                    }, 'json');
                }
            });
        });

    });

</script>

#end